<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>
    <script type="text/javascript" src="js/jquery-3.4.1.js"></script>
</head>
<body>
<h1>用户注册</h1>
<div id="message"></div>
<form id="reg_form" method="post" action="handle_reg">
    <div>
        <label>用户</label>
        <input type="text" name="username">
    </div>
    <div>
        <label>密码</label>
        <input type="password" name="password">
    </div>
    <div>
        <label>年龄</label>
        <input type="number" name="number">
    </div>
    <div>
        <label>电话</label>
        <input type="tel" name="tel">
    </div>
    <div>
        <label>电邮</label>
        <input type="email" name="email">
    </div>
    <input id="reg" type="submit" value="注册">
</form>
<script type="text/javascript">
    $("#reg").click(function () {
        $.ajax({
            type: "post",
            url: "handle_reg",
            data: $("#reg_form").serialize(),
            dataType: "json",
            success: function (result) {
                console.log(result);
                $("#message").text(result.message);
            }
        });
        return false;
    });
</script>
</body>
</html>